import subprocess
 
def is_phone_locked():
    try:
        output = subprocess.check_output(['adb', 'shell', 'dumpsys', 'window', 'windows', '|', 'grep', '-E', '"mCurrentFocus"'], stderr=subprocess.STDOUT)
        if b"LockScreen" in output:
            return True
        return False
    except subprocess.CalledProcessError as e:
        # Handle exception if adb command fails
        print("Error checking phone lock status:", e.output)
        return None
 
phone_locked = is_phone_locked()
if phone_locked:
    print("Phone is locked")
else:
    print("Phone is not locked")